<?php
include_once("functions/db_manipulate.php");

if (!init()) {
    redirect("?action=login");
    exit();
}

?>
    <meta charset="UTF-8">

<?php

connectDB();
startTransaction();

$resultSet = mysql_query("INSERT INTO usrgroup(userid, groupid) VALUES
                                                                        ('" . mysql_real_escape_string($_GET['uid']) . "',
                                                                         '" . mysql_real_escape_string($_GET['gid']) . "')") or die(mysql_error());

$delResultSet = mysql_query("DELETE FROM entergroup WHERE userid = '" . mysql_real_escape_string($_GET['uid']) . "'
                                                          AND
                                                          groupid = '" . mysql_real_escape_string($_GET['gid']) . "'") or die(mysql_error());


if ($resultSet && $delResultSet) {
    commitTransaction();
} else {
    rollbackTransaction();
}

redirect($_SERVER['HTTP_REFERER']);